package com.changgou.goods.dao;

import com.changgou.goods.pojo.Spec;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface SpecMapper extends Mapper<Spec> {

    /**
     * 根据分类名称，，查询对应的规格参数
     * @param categoryName
     * @return
     */
    @Select("select s.`name`, s.`options` from tb_spec s WHERE s.template_id in (SELECT c.template_id from tb_category c where c.`name` = #{categoryName})")
    public List<Map> findSpecByCategoryName(@Param("categoryName") String categoryName);
}
